package servlet.rool;

import pojo.Goods;
import service.GoodsService;
import service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 前台查看商品详情的servlet
 */
@WebServlet(value = "/DetaiServlet")
public class DetaiServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("id");
        GoodsService gs=new GoodsServiceImpl();
        Goods goods=gs.queryGoodsInfo(Integer.parseInt(id));
        request.setAttribute("goods",goods);
        request.getRequestDispatcher("jsp/zc/GoodsDetails.jsp").forward(request,response);
    }
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
        doGet(request, response);
    }
}
